package tianxing

import (
	"encoding/json"
	"fmt"
	ms "gin_template/core/request"
	"strings"
)

// type storyParams struct {
// 	*Params
// 	Word string `json:"word"`
// }

func RequestStory(config interface{}, msg string) string {
	conf := config.(*Config)
	option := "Word=" + msg
	result := &Result{}
	res := ms.RequestPost(conf.Url+"/story/index?key="+conf.Key, option)
	err := json.Unmarshal(res, &result)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println("=====result=====", result)

	var info []string
	for _, content := range result.Newslist {
		info = append(info, content.Content)
	}
	fmt.Println("======info======", strings.Join(info, ","))
	return strings.Join(info, ",")
}
